home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 7160 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.7 KB  |  51 lines

  1. Newsgroups: comp.sys.amiga.programmer
  2. Path: chang.unx.sas.com!walker
  3. From: walker@chang.unx.sas.com (Doug Walker)
  4. Subject: Re: SAS link-error
  5. Sender: news@unx.sas.com (Noter of Newsworthy Events)
  6. Message-ID: <Dpnu0M.99F@unx.sas.com>
  7. Date: Wed, 10 Apr 1996 18:57:58 GMT
  8. X-Nntp-Posting-Host: chang.unx.sas.com
  9. References: <762.6674T1119T1484@academy.bastad.se>
  10. Organization: SAS Institute Inc.
  11.  
  12. In article <762.6674T1119T1484@academy.bastad.se>,
  13. Sten <sten@academy.bastad.se> wrote:
  14. >I get an error when i use a static variable in a C++ Class.
  15. >--
  16. >Undefined symbols        First Referenced
  17. >_medel_betyg__4Kurs      File 'skol_prog.o'
  18. >Enter a DEFINE value for _medel_betyg__4Kurs (default ___stub): 
  19. >Error 510: _medel_betyg__4Kurs symbol - Near Reference to data item not in
  20. >near data section
  21. >--
  22. >I've tried to use far data and near data. Both gave this message:
  23. >--
  24. >Undefined symbols        First Referenced
  25. >_medel_betyg__4Kurs      File 'skol_prog.o'
  26. >Enter a DEFINE value for _medel_betyg__4Kurs (default ___stub): 
  27. >Error 510: _medel_betyg__4Kurs symbol - Near Reference to data item not in near data section
  28. >--
  29. >It works fine when i'm not using static. Please tell me what to do! 
  30. >I don't get all news here - so please send me an Email too.
  31.  
  32. When you declare a static class member, you must include a definition
  33. for that member somewhere:
  34.  
  35.    // This declaration goes in a header file
  36.    class foo
  37.    {
  38.       static int x;
  39.       ...other declarations here...
  40.    };
  41.  
  42.    // This definition goes in a C++ source file
  43.    int foo::x;
  44.  
  45. -- 
  46.   *****     
  47.  *|_o_o|\\     Doug Walker   walker@unx.sas.com  
  48.  *|. o.| ||                
  49.   | o  |//     Any opinions are mine, not those of SAS Institute, Inc.
  50.   ====== 
  51.